package com.java.web;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @Author: wjr
 * @Description:
 * @Date Created in  2020-09-08 16:52
 * @Modified By:
 */
@WebServlet(value = "/test")
public class TestServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;charset=utf-8");
        String username = req.getParameter("username");
        PrintWriter writer = resp.getWriter();

        //验证用户名伪代码
        if ("admin".equals(username)){
            //用户名已存在
            writer.print("用户名已存在");
        }else {
            writer.print("用户名可用");
        }
    }
}
